<template>
	<view class="top1">
		<view class="top2">
				<home-banner :banners="banners"></home-banner>
		</view>
		<view class="top3">
			<view class="top5">
				团长信息
			</view>
			<view class="top4">
				<view class="top6">
					姓名:
				</view>
				<view class="top7">
					<input type="text" placeholder="请输入联系人姓名" class="input-field" v-model="name" value="111111111"/>
				</view>
			</view>
			<view class="top4">
				<view class="top6">
					名称:
				</view>
				<view class="top7">
					<input type="text" placeholder="请输入团长名称" class="input-field" v-model="nickname"/>
				</view>
			</view>
			<view class="top4">
				<view class="top6">
					电话:
				</view>
				<view class="top7">
					<input type="text" placeholder="请输入联系电话" class="input-field" v-model="phone"/>
				</view>
			</view>
			<view class="top4">
				<view class="top6">
					地址:
				</view>
				<view class="top7">
					<input type="text" placeholder="请输入门店地址" class="input-field"  v-model="address"/>
					<view class="top8" @click="weizhi()">
						获取位置
					</view>
				</view>
			</view>
		</view>
		
		<button type="button" class="tijiao" @click="submit()">提交</button>
		<!-- <view class="ewm">
			<img :src="ewm" alt="" srcset=""/>
			<view class="">
				下载二维码
			</view>
		</view> -->
	</view>
</template>

<script>
	export default {
		data(){
			return {
				banners : [
					{title :'11111',image_text:'https://st-gdx.dancf.com/gaodingx/0/uxms/design/20201020-111922-7d85.png'}
				],
				account:'',
				nickname:'',
				name:'',
				phone:'',
				address:'',
				longitude:'',
				latitude:'',
				ewm:'',
				bus_id : 0,
				is_login: 0,
			}
		},
		onShow() {
			
		},
		onLoad(options) {
		
			if (options.q) {
					var q = decodeURIComponent(options.q)
					this.bus_id = q.split('bus_id=')[1].split('&')[0];
					console.log("1111111111111",this.bus_id);
				}
			this.index()
			if(!uni.getStorageSync("token")){
				uni.showModal({
					title: '温馨提示',
					content: '请登入在操作',
					showCancel: true,
					confirmText: "确定",
					success: function (res) {
						if (res.confirm) {
							uni.navigateTo({
								url:'/pages/login/login'
							})
						} else if (res.cancel) {
							
						}
					}
				});
				return false;
			}
			
		},
		methods:{
			submit(){
				if(!uni.getStorageSync("token")){
					uni.showModal({
						title: '温馨提示',
						content: '请登入在操作',
						showCancel: true,
						confirmText: "确定",
						success: function (res) {
							if (res.confirm) {
								uni.navigateTo({
									url:'/pages/login/login'
								})
							} else if (res.cancel) {
								
							}
						}
					});
					return false;
				}
					this.$ajax('post','user/bus_form_add',{
						account:this.account,
						name:this.name,
						nickname:this.nickname,
						avatar:'',
						phone:this.phone,
						address:this.address,
						longitude:this.longitude,
						latitude:this.latitude,
						bus_id : this.bus_id,
						
					}).then(res=>{
						if(res.code==1){
							uni.showToast({
								title:res.msg
							})
						}else{
							uni.showToast({
								title:res.msg
							})
						}
					})
			},
			index(){
				this.$ajax('post','user/bus_form_index',{	
				}).then(res=>{
					this.ewm = res.data.ewm
					this.banners = res.data.banners
				});
			},
			weizhi(){
				// 所在地址
				var _this = this;
				wx.chooseLocation({
					success: function(res) {
						_this.address = res.address
						_this.latitude = res.latitude
						_this.longitude = res.longitude
						
					},
					complete(res) {
						console.log(res, '161');
					}
				})
				
			}
		},
	}
</script>

<style>
	@import "./bus_form.css";
</style>